#pragma once

#include "include/I_LBCPluginMgr.h"
#include "map"
#include "list"
#include "functional"

class LBCPluginMgrImpl : public I_LBCPluginMgr
{
public:
	~LBCPluginMgrImpl();

	virtual void Destroy();

	virtual int QueryInterface(REFIID riid, void** pp);
	virtual int QueryInterface(DWORD dwClassID, void** pp);
	
	virtual int QueryClass(REFIID riid, PDWORD pdwClassID);
	virtual int QueryRiids(DWORD dwClassID, IID* pArr, PDWORD pdwCount);
	
	virtual int RegisterFactory(DWORD dwClassID, REFIID riid, I_LBCPluginFactory* pFactory);

private:
	struct _INNTERITEM 
	{
		DWORD dwClassID;
		IID riid;
		I_LBCPluginFactory* pFactory;
	};

	struct IIDComp : std::binary_function<IID, IID, bool> {
		bool operator()(const IID& _X, const IID& _Y) const
		{ return memcmp(&_X, &_Y, sizeof(IID)) < 0; }
	};


	typedef std::list<IID> DEQ_RIID;
	typedef std::map<DWORD, DEQ_RIID> MAP_CLASS_RIID;
	typedef std::map<IID, _INNTERITEM, IIDComp> MAP_RIID_ITEM;

	MAP_CLASS_RIID m_mapClassRiid;
	MAP_RIID_ITEM m_mapRiidItem;
};